local sk__yanmie = fk.CreateSkill {

  name = "sk__yanmie",

  tags = {},

}



sk__yanmie:addEffect("active", {
  name = "sk__yanmie",
  anim_type = "offensive",
  card_num = 1,
  target_num = 1,
  prompt = "#sk__yanmie",
  can_use = Util.TrueFunc,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).suit == Card.Spade and not player:prohibitDiscard(to_select)
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and not to_select:isNude()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, sk__yanmie.name, player, player)
    local cards = table.filter(target:getCardIds("he"), function(id)
      return not target:prohibitDiscard(id)
    end)
    if #cards == 0 then return end
    target:throwAllCards("he")
    if target.dead then return end
    cards = target:drawCards(#cards, sk__yanmie.name)
    if player.dead or target.dead then return end
    target:showCards(cards)
    if player.dead or target.dead then return end
    cards = table.filter(cards, function(id)
      return table.contains(target:getCardIds("h"), id) and Fk:getCardById(id).type ~= Card.TypeBasic
    end)
    if #cards == 0 then return end
    if room:askForSkillInvoke(player, sk__yanmie.name, nil, "#sk__yanmie-invoke::" .. target.id .. ":" .. #cards) then
      room:throwCard(cards, sk__yanmie.name, target, player)
      if not target.dead then
        room:damage({
          from = player,
          to = target,
          damage = #cards,
          skillName = sk__yanmie.name,
        })
      end
    end
  end,
})

return sk__yanmie
